<!--
描述：添加
开发人：zhaohang
开发日期：2019年10月29日
-->

<template lang="pug">
    kalix-dialog.user-add(bizKey="department" ref="kalixBizDialog" v-bind:formModel.sync="formModel" v-bind:targetURL="targetURL")
        div.el-form(slot="dialogFormSlot")
            input(v-model="formModel.parentId" type="hidden")
            el-form-item(label="上级" prop="departmentName" label-width="120px")
                el-input(v-model="formModel.departmentName" disabled)
            el-form-item(label="根目录" prop="parentId" label-width="120px")
                el-input(v-model="formModel.departmentName" disabled)
            el-form-item(label="名称" prop="name" label-width="120px"  v-bind:rules="rules.name")
                el-input(v-model="formModel.name")
</template>

<script type="text/ecmascript-6">
    import FormModel from './model'
    import {departmentURL} from '../../config.toml'

    export default {
      name: 'SchoolDepartmentAdd',
      data() {
        return {
          departmentName: '',
          formModel: Object.assign({}, FormModel),
          rules: {
            name: [{required: true, message: '请输入名称', trigger: 'blur'}]
          },
          targetURL: departmentURL,
          // schoolZoneURL: schoolZoneURL,
          labelWidth: '110px'
        }
      },
      created() {
      },
      methods: {
        init(dialogOption) {
          // this.formModel.orgName = dialogOption.row.name
          // this.formModel.parentId = dialogOption.row.id
          this.formModel.parentId = dialogOption.parentId
          // 2020-06-19 修改 没有测试 当无数据时添加的parentId应为-1
          this.formModel.parentId = dialogOption.parentId === undefined ? '-1' : dialogOption.parentId
          // this.formModel.departmentName = dialogOption.departmentName
          console.log('dialogOption+++++++++++++', dialogOption)
          // 2020-06-19 修改 underfind ?'学校'
          this.formModel.departmentName = dialogOption.departmentName === undefined ? '根目录' : dialogOption.departmentName
          // console.log('this.formModel================', this.formModel)
        }
      }
    }
</script>
